
global data_folder "W:\intimate\data"
global log_folder "W:\intimate\dofiles\logs"
global output_folder "W:\intimate\results_revision"

// Take sample of DV couples from final restriction and merge back in with crime data 

use  "W:\intimate\data\match_perp_data_clean_new", clear
keep if dv_couple==1

g same_spouse0 = 1
forvalues i = 1/5 {
	g same_spouseB`i' = (sphnro0 == sphnroB`i')
}
forvalues i = 1/5 {
	g same_spouseF`i' = (sphnro0 == sphnroF`i')
}

local varlist ptoim1 tyotu same_spouse

forvalues i = 1/5 {
    local j = 6 -`i'
    foreach thing in `varlist' {
		ren `thing'B`i' `thing'`j'
	}
}

foreach thing in `varlist' {
    ren `thing'0 `thing'6
}

forvalues i = 1/5 {
    local j = 6 +`i'
    foreach thing in `varlist' {
		ren `thing'F`i' `thing'`j'
	}
}

g group_id = _n

reshape long `varlist', i(group_id) j(time)
keep `varlist' time dv_couple
collapse (mean) `varlist', by(time dv_couple)

graph twoway line ptoim1 time if dv_couple==1, lcolor(black) ///
		xlabel(1 "-5" 2 "-4" 3 "-3" 4 "-2" 5 "-1" 6 "0" 7 "1" 8 "2" 9 "3" 10 "4" 11 "5") ///
		xtitle("Time from Cohabitation") ytitle("Employment") ///
		graphregion(color(white)) ylabel(0.4(0.05)0.6) ///
		xline(6, lpattern(dash) lcolor(black))
graph export "$result_folder\perp_descrip_ptoim1.pdf", replace
	
graph twoway line tyotu time if dv_couple==1, lcolor(black) ///
		xlabel(1 "-5" 2 "-4" 3 "-3" 4 "-2" 5 "-1" 6 "0" 7 "1" 8 "2" 9 "3" 10 "4" 11 "5") ///
		xtitle("Time from Cohabitation") ytitle("Earnings") ///
		graphregion(color(white))  ///
		xline(6, lpattern(dash) lcolor(black)) ///
		ylabel(8000(4000)20000)
graph export "$result_folder\perp_descrip_tyotu.pdf", replace


